package com.flyqiu.flow.core.var;

import com.flyqiu.flow.api.script.IVarSerialize;
import com.flyqiu.flow.api.script.FlyQiuFlowVarSerializeManage;
import com.flyqiu.flow.api.script.VarSerialize;

public class LongConverter implements IVarSerialize {
    private static final String TYPE_KEY = Long.class.getName();

    @Override
    public String type() {
        return TYPE_KEY;
    }

    @Override
    public boolean isType(FlyQiuFlowVarSerializeManage manage, Object val) {
        return val instanceof Long;
    }

    @Override
    public VarSerialize serialize(FlyQiuFlowVarSerializeManage manage, Object val) {
        return new VarSerialize(TYPE_KEY, String.valueOf(val), false);
    }

    @Override
    public Object deserialize(FlyQiuFlowVarSerializeManage manage, String val) {
        return Long.valueOf(val);
    }
}
